package com.shengsiyuan.nio;

import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

/**
 * Created by deng_wb on 2019/8/25
 * 内存映射文件
 * MappedByteBuffer
 */
public class NioTest9 {

    public static void main(String[] args) throws Exception {
        RandomAccessFile accessFile = new RandomAccessFile("NioTest9.txt","rw");
        FileChannel fileChannel = accessFile.getChannel();
        MappedByteBuffer mappedByteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE,0,5);
        mappedByteBuffer.put(0,(byte)'a');
        mappedByteBuffer.put(3,(byte)'b');
        accessFile.close();
    }
}
